package br.com.io.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class Dao1<T> {
	
private Class persistenceClass;
    
    private Session session;
    
    public Dao1(Session session, Class persistenceClass){
        this.session = session;
        this.persistenceClass = persistenceClass;
        
    }
    
    public T load(Long id){
        return (T) session.load(persistenceClass, id);
    }
    
    public void save(T t){
        session.save(t);
    }
    
    public void delete(T t){
        session.delete(t);
    }
    
    public void saveOrderby(T t){
        session.saveOrUpdate(t);
    }

    public Dao1(SessionFactory session, Class persistenceClass) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

   

    protected Session getSession() {
        return session;
    }

  
   public List<T> list(){
       return session.createCriteria(persistenceClass).list();
   }
    
   
    
    
    

}
